package aad.storyboard.controller;


import aad.storyboard.model.Scene;
import aad.storyboard.model.Story;
import aad.storyboard.view.BackButton;
import android.app.Activity;

/**
 * Command pattern: will be triggerd if the BackButton is clicked
 */
public class BackNavigator implements NavigateCommand{
	
	private int position=0;
	Scene previousScene=null;	
	private Activity activity;
	private BackButton btn;
	
	public BackNavigator(Activity a)
	{
		this.activity=a;
		btn=GUIComposer.getInstance().getBackButton();
	}

	@Override
	public void navigate() {
		previousScene=Story.getInstance().getCurrentChapter().getPreviousScene();		
		if(previousScene!=null)
		{
		btn.setClickable(true);
		btn.setVisibility(1);
		position=previousScene.getStartTime();
		//AnimationProvider.getInstance().stopAllActiveAnimations();
		//AnimationProvider.getInstance().undoAllAnimationsBackToTime(position);
		ControllerManager.getInstance().startStory(previousScene);
		System.out.println("prevPosition"+position);
		}
		else
		{
			btn.setClickable(false);
			btn.setVisibility(0);
			btn.postInvalidate();
		}
		
	}

	

}
